#include "RsGisLibRGISCopyGDALATTCol.h"
#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include <QVariant>

RsGisLibRGISCopyGDALATTCol::RsGisLibRGISCopyGDALATTCol(RsgisPortal* ClientPortal, QWidget *parent)
{
	ui = new Ui::RsGisLibRGISCopyGDALATTCol();
	ui->setupUi(this);

	Portal = ClientPortal;

	connect(ui->pushButton_InputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_InputFilePath_clicked()));
	connect(ui->pushButton_ClumpsFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_ClumpsFilePath_clicked()));
	connect(ui->pushButton_FieldsFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_FieldFilePath_clicked()));
	connect(ui->pushButton_Excecute, SIGNAL(clicked()), this, SLOT(on_action_Button_Excecute_clicked()));

	ui->lineEdit_InputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_ClumpsFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_FieldsFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");

	QStringList FlagList;
	FlagList.append("False");
	FlagList.append("True");
	ui->comboBox_copyColours->addItems(FlagList);
	ui->comboBox_copyHist->addItems(FlagList);

	ui->lineEdit_ratBand->setText("0");
	ui->comboBox_copyColours->setCurrentIndex(0);
	ui->comboBox_copyHist->setCurrentIndex(0);

	ui->lineEdit_Priority->setText("16");
}

void RsGisLibRGISCopyGDALATTCol::on_action_Button_InputFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_InputFilePath->setText(str.toUtf8());
}

void RsGisLibRGISCopyGDALATTCol::on_action_Button_ClumpsFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_ClumpsFilePath->setText(str.toUtf8());
}

void RsGisLibRGISCopyGDALATTCol::on_action_Button_FieldFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_FieldsFilePath->setText(str.toUtf8());
}

void RsGisLibRGISCopyGDALATTCol::on_action_Button_Excecute_clicked()
{
	QList<QVariant> SysParaList;
	SysParaList << QVariant(QString("RsGisLib"));
	SysParaList << QVariant(QString("RasterGIS"));
	SysParaList << QVariant(int(ui->lineEdit_Priority->text().toInt()));

	QList<QVariant> AlgParaList;
	AlgParaList << QVariant(QString("CopyGDALATTCol"));
	AlgParaList << QVariant(QString(ui->lineEdit_InputFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_ClumpsFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_FieldsFilePath->text()));
	AlgParaList << QVariant(int(ui->comboBox_copyColours->currentIndex()));
	AlgParaList << QVariant(int(ui->comboBox_copyHist->currentIndex()));
	AlgParaList << QVariant(int(ui->lineEdit_ratBand->text().toInt()));

	QVariantList ArgList;
	ArgList << (QVariant)SysParaList;
	ArgList << (QVariant)AlgParaList;

	Portal->goAhead(ArgList);
}